package hn.sigit.view.converter;

import hn.sigit.dao.ladm.spatialunit.LA_LevelDAO;
import hn.sigit.model.ladm.spatialunit.LA_Level;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public class LA_LevelConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		return LA_LevelDAO.loadLevelById(Long.parseLong(value));
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		if (value == null) return "";
		
		return String.valueOf(((LA_Level) value).getIID());
	}

}
